<? 
//Neu da submit thi thuc hien gui e-mail
$head = "<img src=\"http://www.vietcms.com/images/mailbanner.gif\" width=\"700\" />";
$head .="<table width=\"700\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><br><br>";


$footer = '</td></tr></table><p>&nbsp;</p><table width="700" border="0" cellspacing="0" cellpadding="0"><tr><td height="5" bgcolor="#3D8FDC"></td></tr></table><h4>Viet CMS Design Center</h4>telephone: 08. 9443 945 <br />cell phone: 0909 10 11 76<br />website: www.vietcms.com<br />e-mail: <a href="mailto:info@vietcms.com"><span style="margin:10px">info@vietcms.com</span></a> <br />&#273;&#7883;a ch&#7881;: 159/1/3 Bach Dang, F.2, Q.Tan Binh, Tp.HCM, Vietnam.</p>';
	if (isset($_POST['butSub']))
	{		
			require("../inc/class.phpmailer.php");
			$mail = new PHPMailer();
			$mail->IsSMTP(); // telling the class to use SMTP
			//$mail->Host = "smtp.vietcm.com"; // SMTP server
			$mail->CharSet = 'utf-8';			
			$mail->From = 'info@vietcms.com';
			$mail->FromName = trim($_POST['name']);
			$mail->AddAddress(trim($_POST['re_email']));
			
			$mail->Subject =  trim($_POST['subject']);
			$mail->Body = $head.nl2br (trim($_POST['mess'])).$footer;

			//$mail->WordWrap = 50;
			$mail->IsHTML(true);
			
			if(!$mail->Send())
			{
			 	   echo '<script>alert("Gửi không thành công !");</script>';
					echo '<script>location.href = "./index.php?act=sendmail";</script>';
			  // echo 'Mailer error: ' . $mail->ErrorInfo;
			}
			else
			{
			   		echo '<script>alert("Gửi thành công !");</script>';
					echo '<script>location.href = "./index.php?act=sendmail";</script>';
			}
	}		
?>

<form id="form1" name="form1" method="post" action="">
  <table width="100%" border="1" cellpadding="4" cellspacing="0" bordercolor="#99CCCC" style="border-collapse:collapse">
    <tr>
      <td bordercolor="#99CC00">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td align="right">Ti&ecirc;u &#273;&#7873; mail  </td>
      <td><input name="subject" type="text" id="subject" size="60" /></td>
    </tr>
    <tr>
      <td align="right" valign="top">Tên Người Gửi </td>
      <td><input name="name" type="text" id="name" size="60" /></td>
    </tr>
    <tr>
      <td align="right" valign="top">email Người nhận </td>
      <td><input name="re_email" type="text" id="re_email" size="60" /></td>
    </tr>
    <tr>
      <td align="right" valign="top">N&#7897;i dung mail </td>
      <td><textarea name="mess" cols="60" rows="10" id="mess"></textarea></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="butSub" value="Gửi đi" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>
